<div class="crumb-wrap">
    <div class="crumb-list"> <i class="icon-font"></i>
        <a href="<?=site_url()?>">首页</a>
        <span class="crumb-step">&gt;</span>
        <span class="crumb-name">订单管理</span>
    </div>
</div>

<div class="search-wrap">
    <div class="search-content" style="margin-left: 20px">
        <a href="<?=site_url('order/index')?>" class="btn btn6 <?=empty($sid) ? 'btn-primary' : ''?> mr10">全部订单 <?=$all_count?></a>
        <!-- 订单状态 -->
        <?php foreach($status as $k => $v):?>
        <a href="<?=site_url('order/index?sid='.$k)?>" class="btn <?=$sid == $k ? 'btn-primary' : ''?> btn6 mr10"><?=$v?> <?=$count[$k]?></a>
        <?php endforeach; ?>
    </div>
</div>

<div class="result-wrap">
    <form name="myform" id="myform" method="post">
        <div class="result-content">
            <table class="result-tab" width="100%">
                <tr>
                    <th>订单编号</th>
                    <th>订单状态</th>
                    <th>项目名称</th>
                    <th>所需积分</th>
                    <th>系统备注</th>
                    <th>联系人</th>
                    <th>联系电话</th>
                    <th>更新时间</th>
                    <th>操作</th>
                </tr>
                <?php foreach($list as $k => $v):?>
                <tr>
                    <td><?=$v['id']?></td>
                    <td style="color:<?=$v['status'] < 2 ? 'red' : ''?>"><?=$v['status_name']?></td>
                    <td title="项目名称">
                        <a href="javascript:;" title="<?=$v['par']['title']?>" onclick="open_view('<?=site_url('article/show?aid='.$v['par']['article_id'])?>')"><?=$v['par']['title']?></a>
                    </td>
                    <td><?=$v['price']?></td>
                    <td><pre><?=$v['remarks']?></pre></td>
                    <td><?=$v['user_name']?></td>
                    <td><?=$v['user_phone']?></td>
                    <td><?=date('Y-m-d H:i:s',$v['update_time'])?></td>
                    <td>
                        <a class="link-del" href="<?=site_url('order/oinfo?oid='.$v['id'])?>">详情</a>
                        <?php if($v['status'] < 2): ?>
                            <a class="link-del" href="javascript:;" onclick="del_order(<?=$v['id']?>)">删除</a>
                        <?php endif;?>

                        <?php if($v['status'] > 0 && !empty($v['user_remarks'])): ?>
                            <a class="link-update" href="javascript:;" onclick="open_view('<?=site_url('order/show_remarks?oid='.$v['id'])?>')">备注</a>
                        <?php endif;?>

                    </td>
                </tr>
                <?php endforeach;?>

            </table>
            <div class="list-page"><?=$page?></div>
        </div>
    </form>
</div>
<script type="text/javascript">
    function open_view(url){
        layer.open({
            type: 2,
            area: ['800px', '600px'],
            fix: false, //不固定
            maxmin: true,
            content: url
        });
    }

    function del_order(oid){
        layer.confirm('删除之后不可恢复，是否确定？', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.post("<?=site_url('order/delete')?>",{oid:oid},function(data){
                if(data == 1){
                    layer.alert("操作成功！",{
                        icon:1,
                    },function(){
                        location.reload();
                    });
                }else{
                    layer.alert(data,{
                        icon:2,
                    });
                }
            });
        });
    }
</script>